home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 9
/
Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO
/
050a
/
bfmt139.zip
/
BFMT139.DOC
< prev
next >
Wrap
Text File
|
1993-04-28
|
13KB
|
506 lines
BFMT.EXE ----------------------------------------------------
This program is free and you are welcome to use it at your own
risk. If you pass it on please give this accompanying document as
well.
Also if you do use it, or a modified form of it, please acknowledge
the original author: Brendan Babb.
If you modify, improve upon, or have suggestions for this program
Please email me (Brendan@micro.uct.ac.za).
-----------------------------------------------------------------
BFMT.EXE - text formatting
What can bfmt do ?
* align text
* format paragraphs - centre
- left
- right
- justified
- unchanged
* inherit whitespace or specify whitespace
* embedded formatting options in the text
What does it work on?
* bfmt is really designed for use with vi like editors
such as elvis
* you can bfmt any text file from the command line
by 'TYPE {filename} | BFMT [options] [>{filename}]'
or 'BFMT [options] <{input} >{output}'
/-----------------------------------------------------------------
How do I use BFMT ?
You can use the program from either the command line or from
within an editor like elvis. From the command line if you run
'BFMT' input will be taken from the keyboard and outputed to
the screen. This isnt particularly useful but with
redirection you can save text entered and/or input from a
file.
For example 'BFMT >output.txt' will take whatever you type as
input and save the output to the file output.txt. It will
save whatever text entered (until you type ^Z) in formatted
form in the file output.txt. Similarly 'BFMT <input.txt
>output.txt' will take text from input.txt and save it in
output.txt. Alternatively 'TYPE input.txt | >>output.txt' will
take input.txt as input and append the output to the file
output.txt.
If you use vi-like editors (elvis) you can map various
options to different keys. I've mapped '!}BFMT -fl' to Alt-L
and '!}BFMT -fj' to Alt-J etc. These mappings format the
text from the cursor's line through till the end of the
current paragraph. See the examples below for what the
various options on formatting actually are.
A few notes: bfmt thinks in words, lines and paragraphs. So
separate paragraphs with blank lines, or lines beginning with
paragraph markers. Otherwise specify the option to treat each
line as a separate paragraph. Bfmt works by collecting as
many words as it can before it reaches a new paragraph. These
words and the last input line are passed to formatting
functions. If a line beginning with a paragraph marker is
found, then that line is saved to a parameter buffer. This
buffer is dealt with after formatting and output, so that only
subsequent paragraphs are affected by it.
/-----------------------------------------------------------------
Option Summary
-? display options and defaults
-a{0|1} all lines treated as paragraphs or not
-f{a|c|l|r|j|u} format type
note that -fa indents c/c++ text for you
-h display options and defaults
-i{0|1} inherit whitespace or not
-m{number} minimum number of words to format in justify
-s{number} amount of whitespace when -i0
-t{0|1} to follow text embedded options
the following options are recognised
-a, -w, -f, -i, -k, -s, -h (current defaults), -w
-v display version
-w{number} right margin
-{{list} list of paragraph identifiers (for recognizing
text embedded options)
-({list} list of sentence markers (gets a forced double space
afterwards)
-u save the options previously listed on command line
as the defaults.
? display options and defaults
/------------------- EXAMPLES -----------------
The following are examples of bfmt in action. All the examples
use the text below as their input. I ran bfmt from elvis 1.7
by using the following command
:r !bfmt <sample [options]
This looks rather messy, but the output looks neater!
-------> begin sample text
// ------------- Sample text. ---------------
#define
// practice c
main () {
sample com1
com2
for (int i = ; ; ) {
do this
do that
do nothing
}
wait around and make mistakes
}
// practice text
This is sample test.
This is sample test.
This is sample test.
line two
line three
And more sample text.
.-w50 -fr
with still even more text to use ansd reuse
blah blah blah blah hi world bye world
Last line.
// -------------------------------------- ----------------
---------> end sample text
Example 1 : BFMT
In this example, the defaults as supplied are used. All text
is assumed to be paragraphs. As many words as possible are
crammed into each line. Note that the embedded commands are
obeyed to produce a right format paragraph.
---------> begin output
// ------------- Sample text. ---------------
#define
// practice c
main () { sample com1 com2 for (int i = ; ; ) { do this do that do
nothing } wait around and make mistakes }
// practice text
This is sample test. This is sample test. This is
sample test. line two line three And more sample text.
.-w50 -fr
with still even more text to use ansd
reuse blah blah blah blah hi world bye
world
Last line.
// -------------------------------------- ----------------
---------> end output
Example 2 : BFMT -t0
In this example bfmt is told not obey options embedded in the
text itself (ie -w50 -fr). The last paragraph is no longer
right formatted.
----------> begin output
// ------------- Sample text. ---------------
#define
// practice c
main () { sample com1 com2 for (int i = ; ; ) { do this do that do
nothing } wait around and make mistakes }
// practice text
This is sample test. This is sample test. This is
sample test. line two line three And more sample text.
.-w50 -fr
with still even more text to use ansd reuse blah blah blah
blah hi world bye world
Last line.
// -------------------------------------- ----------------
---------> end output
Example 3 : BFMT -i0
Here, BFMT is told not to inherit whitespace, but to use the
default -s{} setting (8). Notice that the lines beginning with /
are still aligned to the very left. This is because BFMT has
been told ( -{ ) to see / as a paragraph marker.
---------> begin output
// ------------- Sample text. ---------------
#define
// practice c
main () { sample com1 com2 for (int i = ; ; ) { do this do
that do nothing } wait around and make mistakes }
// practice text
This is sample test. This is sample test. This is sample test.
line two line three And more sample text.
.-w50 -fr
with still even more text to use ansd
reuse blah blah blah blah hi world bye
world
Last line.
// -------------------------------------- ----------------
---------> end output
Example 4. : BFMT -a1
Each line is assumed to be a separate paragraph here. The
affect is that any lines that are too long will be chopped
into two lines and white space within a line is reduced to
single spaces.
---------> begin output
// ------------- Sample text. ---------------
#define
// practice c
main () {
sample com1
com2
for (int i = ; ; ) {
do this
do that
do nothing
}
wait around and make mistakes
}
// practice text
This is sample test.
This is sample test.
This is sample test.
line two
line three
And more sample text.
.-w50 -fr
with still even more text to use ansd
reuse blah blah blah blah hi world bye world
Last line.
// -------------------------------------- ----------------
---------> end output
Example 5. : BFMT -fa -s0
This is format align - it indents c-code but otherwise aligns all
lines to a specific left margin. Notice that internal tabs and
white spaces are kept. Lines beginning with # or
/ are sent to space 0. Every time a { is encountered
indentation is increased by 8 on the next line and every } is
found indentation is reduced by 8.
---------> begin output
// ------------- Sample text. ---------------
#define
// practice c
main () {
sample com1
com2
for (int i = ; ; ) {
do this
do that
do nothing
}
wait around and make mistakes
}
// practice text
This is sample test.
This is sample test.
This is sample test.
line two
line three
And more sample text.
.-w50 -fr
with still even more text to use ansd
reuse blah blah blah blah hi world bye
world
Last line.
// -------------------------------------- ----------------
---------> end output
Example 6 : BFMT -fj -w60 -i0
There is also format unchanged right aligned, justified (as
in here) or centered.
---------> begin output
// ------------- Sample text. ---------------
#define
// practice c
main () { sample com1 com2 for (int i = ; ; ) { do
this do that do nothing } wait around and make
mistakes }
// practice text
This is sample test. This is sample test. This is
sample test. line two line three And more sample
text.
.-w50 -fr
with still even more text to use ansd
reuse blah blah blah blah hi world bye
world
Last line.
// -------------------------------------- ----------------
---------> end output
Example 7. : BFMT -k0
This tells bfmt to not reprint text directives. ie all
those lines that begin with a paragraph marker.
---------> begin output
#define
main () { sample com1 com2 for (int i = ; ; ) { do this do that do
nothing } wait around and make mistakes }
This is sample test. This is sample test. This is
sample test. line two line three And more sample text.
with still even more text to use ansd
reuse blah blah blah blah hi world bye
world
Last line.
---------> end output
Example 8. : BFMT -v
This just displays the version and nothing else.
---------> begin output
Brendan's format program version 1.39
---------> end output
Example 9. : BFMT -h
This displays the list of options and current defaults
---------> begin output
Text formatting version 1.39
send donations to Brendan Babb
@ microbiol dept, Univ. Ave, UCT, Rondebosch 7700, RSA
USAGE: BFMT [options listed below]
[<{input}] [>{output}] where input and output are filenames
[-f{type}] types are l,r,j,c,u,a
[-i{0|1}] inherit whitespace [-s{width}] whitespace width
[-a{0|1}] all lines are paragraphs
[-t{0|1}] obey options in text
[-k{0|1}] keep options in text
[-({sentence delimiters}] [-{{paragraph delimiters}]
[-w{width}] right margin
[-m{min}] minimum words to justify
[/u] save previous options to default
[?|-h|-?] display this and current defaults
Current default values :
sentence markers .?!* paragraph markers ./
paragraph spacing 8 all lines as para 0
keep param lines 1 obey param lines 1
format l whitespace inhertited 1
width 72 minimum words to fmt 4
---------> end output
Example 10 : BFMT -w80 /u
This will reset the width (right margin) to 80 and will save
this information in the .EXE file that you ran.
---------> begin output
// ------------- Sample text. ---------------
#define
// practice c
main () { sample com1 com2 for (int i = ; ; ) { do this do that do nothing }
wait around and make mistakes }
// practice text
This is sample test. This is sample test. This is sample test.
line two line three And more sample text.
.-w50 -fr
with still even more text to use ansd
reuse blah blah blah blah hi world bye
world
Last line.
// -------------------------------------- ----------------
---------> end output
AND SO ON....................................